package com.gperp.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.gperp.common.GPResult;
import com.gperp.common.StringUtils;
import com.gperp.pojo.AsRole;
import com.gperp.service.RoleService;

@Controller
public class RoleController {
	@Resource
	private RoleService roleService;//
	
	@RequestMapping(value="roleList",method=RequestMethod.GET)
	@CrossOrigin
	@ResponseBody
	public List<AsRole> roleList(){
		return roleService.queryList();
	}
	
	@RequestMapping(value="roleListStart",method=RequestMethod.GET)
	@CrossOrigin
	@ResponseBody
	public List<AsRole> roleListStart(){
		return roleService.queryListStart();
	}
	
	@RequestMapping(value="queryRoleById",method=RequestMethod.GET)
	@CrossOrigin
	@ResponseBody
	public AsRole queryRoleById(Long id){
		return roleService.queryRoleById(id);
	}
	
	@RequestMapping(value="checkName",method=RequestMethod.GET)
	@CrossOrigin
	@ResponseBody
	public GPResult checkName(String rolename){
		return roleService.checkName(StringUtils.getGetString(rolename));
	}
	
	@RequestMapping(value="saveRole",method=RequestMethod.POST)
	@CrossOrigin
	@ResponseBody
	public GPResult saveRole(AsRole role){
		return roleService.saveRole(role);
	}
	
	@RequestMapping(value="updateRole",method=RequestMethod.POST)
	@CrossOrigin
	@ResponseBody
	public GPResult updateRole(AsRole role){
		return roleService.updateRole(role);
	}
	
	@RequestMapping(value="deleteRoleById",method=RequestMethod.GET)
	@CrossOrigin
	@ResponseBody
	public GPResult deleteRoleById(Long id){
		return roleService.deleteRoleById(id);
	}
}
